#{extends 'admin.html' /}
#{set title:'Administration : Création d\'un Groupe' /}
#{if flash.error}
    <h4 class="alert_error">${flash.error}</h4>
#{/if}



<article class="module width_full">
    <header><h3 class="tabs_involved">Ajouter une formation</h3>
        <ul class="tabs">
            <li><a href="@{Groups.list}">Annuler</a></li>
        </ul>

    </header>

    <div class="entity">
        #{form @Formations.save(), id:'createForm'}
        <div class="module_content">
            <fieldset>
                <label>Nom de la formation : </label>
                <input type="text" name="entity.name" value="${entity?.name}"/>
                <span class="error">${errors.forKey('entity.name')}</span>
                
                
            </fieldset>
            <fieldset>
                <label>Description de la formation : </label>
                <input type="text" name="entity.description" value="${entity?.description}"/>
                <span class="error">${errors.forKey('entity.descrition')}</span>
                

            </fieldset>
            <fieldset>
                <label>Durée de la formation : </label>
                <input type="text" name="entity.duration" value="${entity?.duration}"/> (H)
                <span class="error">${errors.forKey('entity.duration')}</span>
                

            </fieldset>
            <fieldset>
                <label>Prix de la formation : </label>
                <input type="text" name="entity.price" value="${entity?.price}"/> (€)
                <span class="error">${errors.forKey('entity.price')}</span>
                

            </fieldset>
            <fieldset>
                <label>Type de formation : </label>
                <select name="entity.formationtype.id">
                          
              
        %{ models.FormationType.all().fetch().sort{ it.toString() }.each() { }%
          
          %{
            selected = false;
            if (entity?.formationtype?.id == it.id) {
              selected = true
            }
          }%
          <option value="${it?.id}" ${selected ? 'selected'.raw() : ''}>${it}</option>
        %{ } }%
        </select>
                <span class="error">${errors.forKey('entity.formationtype')}</span>
            </fieldset>
            <input type="submit" name="submit" value="Créer !" class="alt_btn"/>
         </div>
         
		#{/form}
	</div>
	
</article>

